package com.example.androidrobot;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.RectF;
import android.os.Build;
import android.view.View;

import androidx.annotation.RequiresApi;

public class MyView extends View {
    public MyView(Context context) {
        super(context);
    }

    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        Paint paint=new Paint();
        paint.setAntiAlias(true);
        //画头
        RectF rectF=new RectF(250,200,750,700);
        paint.setColor(0x00000000);
        canvas.drawRect(rectF,paint);
        paint.setColor(0xFF00730F);
        canvas.drawArc(rectF,-10,-160,false,paint);
        //眼睛
        paint.setColor(0xFFFFFFFF);
        canvas.drawCircle(380,320,20,paint);
        canvas.drawCircle(620,320,20,paint);
        //触角
        paint.setStrokeWidth(15);
        paint.setColor(0xFF00730F);
        canvas.drawLine(400,300,320,120,paint);
        canvas.drawLine(600,300,680,120,paint);
        //身体
        canvas.drawRect(250,450,750,800,paint);
        canvas.drawRoundRect(250,450,750,900,50,50,paint);
        //手
        canvas.drawRoundRect(120,450,220,800,50,50,paint);
        canvas.drawRoundRect(780,450,880,800,50,50,paint);
        //jio
        canvas.drawRoundRect(350,850,450,1150,50,50,paint);
        canvas.drawRoundRect(650,850,550,1150,50,50,paint);

    }
}
